/*
 * @Description: 用于 UI 状态
 * @Author: XuYang 
 * @Date: 2019-06-09 10:40:40 
 * @Last Modified by: XuYang
 * @Last Modified time: 2019-06-12 13:31:29
 */
import {Alert } from 'react-native'
import { observable, action, computed, runInAction } from 'mobx';

export default class UIStore {
  
  @observable errorMsg = null;
  @observable loading = false;
  
  constructor() {
  }

  @action.bound setErrorMsg = (msg) => {
    Alert.alert(
      '提示',
      msg,
      [
      { text: '关闭'}
      ],
      { cancelable: false }
    )
  }
  @action.bound setSuccess = (msg) => {
    Alert.alert(
      '成功',
      msg,
      [
      { text: '关闭'}
      ],
      { cancelable: false }
    )
  }

  @action.bound setLoading = (isLoading) => {
    this.loading = isLoading;
  }

  @computed get hasError() {
    return this.errorMsg !== null;
  }

  @computed get isLoading() {
    return this.loading;
  }
}

